#include <sys/types.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <stdio.h>
#define FNAME "/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT1/capacity"
int main(void)
{
    char buff[2];
    int fd = open(FNAME,O_RDONLY); 
    read(fd, buff, sizeof(buff));
    if(buff[0]==49&&buff[1]!=48)
    {
	if(buff[1]>=54&&buff[1]<=57)
	{
		system("slock");
	}else{
		system("systemctl suspend");
	}
    }
    close(fd);
    return 0;
}

